{php include wl_template('common/header');}
<ul class="nav nav-tabs">
    <li class="active"><a href="javascript:;">黄页管理</a></li>
</ul>
<div class="app-content">
    <div class="app-filter">
        <div class="filter-action">
            <a href="{php echo web_url('yellowpage/yellowpage/page_edit')}" class="btn btn-primary">添加黄页</a>
        </div>
        <div class="filter-list">
            <form class="form-horizontal" action="" method="get">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{MODULE_NAME}" />
                <input type="hidden" name="p" value="yellowpage" />
                <input type="hidden" name="ac" value="yellowpage" />
                <input type="hidden" name="do" value="page_lists" />
                <div class="form-group" style="max-width: 1180px;">
                    <label class="col-sm-2 control-label">审核</label>
                    <div class="col-sm-9">
                        <div class="btn-group">
                            <a href="{php echo wl_filter_url('status:');}" class="btn {if empty($_GPC['status'])}btn-primary{else}btn-default{/if}">不限</a>
                            <a href="{php echo wl_filter_url('status:4');}" class="btn {if $_GPC['status'] == '4'}btn-primary{else}btn-default{/if}">待审核</a>
                            <a href="{php echo wl_filter_url('status:1');}" class="btn {if $_GPC['status'] == '1'}btn-primary{else}btn-default{/if}">已审核</a>
                            <a href="{php echo wl_filter_url('status:2');}" class="btn {if $_GPC['status'] == '2'}btn-primary{else}btn-default{/if}">被驳回</a>
                            <a href="{php echo wl_filter_url('status:3');}" class="btn {if $_GPC['status'] == '3'}btn-primary{else}btn-default{/if}">未支付</a>
                        </div>
                    </div>
                </div>
                <div class="form-group" style="max-width: 1180px;">
                    <label class="col-sm-2 control-label">状态</label>
                    <div class="col-sm-9">
                        <div class="btn-group">
                            <a href="{php echo wl_filter_url('tStatus:');}" class="btn {if empty($_GPC['tStatus'])}btn-primary{else}btn-default{/if}">不限</a>
                            <a href="{php echo wl_filter_url('tStatus:1');}" class="btn {if $_GPC['tStatus'] == '1'}btn-primary{else}btn-default{/if}">启用</a>
                            <a href="{php echo wl_filter_url('tStatus:2');}" class="btn {if $_GPC['tStatus'] == '2'}btn-primary{else}btn-default{/if}">禁用</a>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label">黄页信息</div>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="name" value="{$_GPC['name']}" placeholder="请输入黄页名称">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label"></div>
                    <div class="col-sm-9">
                        <button class="btn btn-primary" type="submit">搜索</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="app-table-list">
        {if !empty($lists)}
        <div class="table-responsive">
            <table class="table table-hover table-bordered">
                <thead>
                <tr>
                    <th class="text-center"><input type="checkbox" /></th>
                    <th class="text-center">黄页信息</th>
                    <th class="text-center">所属用户</th>
                    <th class="text-center">关联套餐</th>
                    <th class="text-center">统计</th>
                    <th class="text-center">审核</th>
                    <th class="text-center">状态</th>
                    <th class="text-center">操作</th>
                </tr>
                </thead>
                <tbody>
                {loop $lists $list}
                <tr class="text-center">
                    <td>
                        <input type="checkbox" value="{$list['id']}" />
                    </td>
                    <td class="name text-left">
                        <div style="display: flex">
                            <img class="img-40" src="{php echo tomedia($list['logo'])}" style="border-radius:50%;border:1px solid #efefef;margin-top: 20px;" onerror="this.src='../addons/{MODULE_NAME}/web/resource/images/nopic-small.jpg'" height="40" width="40">
                            <span style="display: flex;flex-direction: column;justify-content: center;align-items: flex-start;padding-left: 5px">
                                    <p><b>黄页名称：</b>{$list['name']}</p>
                                    <p><b>所属分类：</b>{$list['one_class_name']} - {$list['two_class_name']}</p>
                                    <p><b>入驻时间：</b>{php echo date('Y-m-d H:i:s', $list['createtime'])}</p>
                                </span>
                        </div>
                    </td>
                    <td>
                        {if !empty($list['member'])}
                        <img class="img-40" src="{php echo tomedia($list['member']['avatar'])}" style="border-radius:50%;border:1px solid #efefef;" onerror="this.src='../addons/{MODULE_NAME}/web/resource/images/nopic-small.jpg'" height="40" width="40">
                        <br>{$list['member']['nickname']}<br>
                        {$list['member']['mobile']}
                        {else}
                        平台添加
                        {/if}
                    </td>
                    <td>
                        <p><b>套餐名称：</b>{$list['meal']['name']}</p>
                        <p><b>套餐明细：</b>￥{$list['meal']['price']}/入驻{$list['meal']['day']}天</p>
                        {if $list['meal_endtime'] > 0 }
                        <p><b>到期时间：</b>{php echo date('Y-m-d H:i:s', $list['meal_endtime'])}</p>
                        {/if}
                    </td>
                    <td>
                        <p><b>浏览：</b>{$list['pv']}</p>
                        <p><b>收藏：</b>{$list['collect']}</p>
                        <p><b>分享：</b>{$list['share']}</p>
                    </td>
                    <td style="position: relative;">
                        {if $list['paystatus'] > 0}
                        <div class="btn-group" style="width: 68px;">
                            <button class="btn btn-sm {$checkstatus[$list['checkstatus']]['class']} dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{$checkstatus[$list['checkstatus']]['text']}</button>
                            <ul class="dropdown-menu" style="width: 68px;min-width: 68px;">
                                {if $list['checkstatus'] != 0}
                                <li><a href="{php echo web_url('yellowpage/yellowpage/page_check_status', array('id'=>$list['id'],'status'=>0))}" data-toggle="ajaxRemove" data-confirm="确认修改为待审核吗？" style="margin: 0;">待审核</a></li>
                                {/if}
                                {if $list['checkstatus'] != 1}
                                <li><a href="{php echo web_url('yellowpage/yellowpage/page_check_status', array('id'=>$list['id'],'status'=>1))}" data-toggle="ajaxRemove" data-confirm="确认通过审核吗？" style="margin: 0;">通过</a></li>
                                {/if}
                                {if $list['checkstatus'] != 2}
                                <li><a href="javascript:;" class="rejectdis" appid = "{$list['id']}"  style="margin: 0;">驳回</a></li>
                                {/if}
                            </ul>
                        </div>
                        {else}
                        <label class="label">未支付</label>
                        {/if}
                    </td>
                    <td>
                        {php echo tpl_change_status('yellowpage/yellowpage/page_status&id='.$list['id'], $list['status'])}
                    </td>
                    <td>
                        <a class="btn btn-sm btn-default" href="{php echo web_url('yellowpage/yellowpage/page_edit', array('id' => $list['id']))}">编辑</a>
                        <a class="btn btn-sm btn-default" data-toggle="ajaxRemove" href="{php echo web_url('yellowpage/yellowpage/page_del', array('id' => $list['id']))}" data-confirm="确定删除当前黄页?">删除</a>
                    </td>
                </tr>
                {/loop}
                </tbody>
            </table>
        </div>
        <div class="app-table-foot clearfix">
            <div class="pull-left">
                <button class="btn btn-default" type="button" data-toggle='batch-remove' data-confirm="确定删除当前选择的黄页？" data-href="{php echo web_url('yellowpage/yellowpage/page_del')}">批量删除</button>
                <button class="btn btn-default" type="button" data-toggle='batch' data-href="{php echo web_url('yellowpage/yellowpage/page_check_status', array('status'=>1))}">批量通过</button>
                <button class="btn btn-default allreject" type="button" data-toggle='batch' href="javascript:;">批量驳回</button>
            </div>
            <div class="pull-right">
                {$pager}
            </div>
        </div>
        {else}
        <div class="no-result">
            <p>还没有相关数据</p>
        </div>
        {/if}
    </div>

    <div id="modal-module-gift22" class="modal fade" tabindex="-1">
        <div class="modal-dialog" style='width: 920px;'>
            <div class="modal-content">
                <div class="modal-header">
                    <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                    <h3>驳回理由</h3></div>
                <div class="modal-body" style="padding: 0;">
                    <div class="modal-body">
                        <textarea id="remark" name="admin_remark" class="form-control" rows="5"></textarea>
                    </div>
                </div>
                <div class="modal-footer" style="padding:15px;">
                    <a class="btn btn-default js-cancel" aria-hidden="true" data-dismiss="modal">取消</a>
                    <a class="btn btn-primary js-order-id-post" order-id="" data-dismiss="modal" aria-hidden="true">确定</a>
                </div>
            </div>
        </div>
    </div>

</div>
<script>
    var div = $(".table-responsive");
    //驳回申请理由
    $('.rejectdis').click(function(){
        var appid = $(this).attr('appid');
        $('.js-order-id-post').attr("order-id",appid);
        popwin = $('#modal-module-gift22').modal();
    });

    $('.allreject').click(function(){
        var appid = get_selecteds();
        console.log(appid);
        $('.js-order-id-post').attr("order-id",appid);
        popwin = $('#modal-module-gift22').modal();
    });

    $('.js-cancel').click(function(){
        $('.allreject').removeAttr("disabled");
        $('.allreject').html('批量驳回');
    });


    var get_selecteds = function () {
        var selected_checkboxs = $('tbody tr td:first-child [type="checkbox"]:checked', div);
        selecteds = selected_checkboxs.map(function () {
            return $(this).val()
        }).get();
        return selecteds
    };


    $('.js-order-id-post').click(function() {
        var order_id = $(this).attr('order-id');
        var remark = $('#remark').val();
        $.post("{php echo web_url('yellowpage/yellowpage/page_check_status')}",{id:order_id,reason:remark,status:2},function(d){
            if(!d.errno){
                util.tips('驳回成功!');
                location.reload();
            }
        },"json");
        //$('#order-remark-container').hide();
        $('.main').css("opacity","1");$('.nav').css("opacity","1");$('.big-menu').css("opacity","1");
    });

</script>
{php include wl_template('common/footer');}